package com.example.mobile2021606177cke0415;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class PeopleAdapter extends RecyclerView.Adapter<PeopleAdapter.ViewHoder> {
    String[]names;
    public PeopleAdapter(String[]names){
        this.names=names;
    }
    @NonNull
    @Override
    public ViewHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).
                inflate(R.layout.item_rv_main_pepole,parent,false);
        ViewHoder viewHoder=new ViewHoder(view);
        return viewHoder;

    }

    @Override
    public void onBindViewHolder(@NonNull ViewHoder holder, int position) {
        holder.tvItemName.setText(names[position]);

    }

    @Override
    public int getItemCount() {
        return names.length;
    }

    static class ViewHoder extends RecyclerView.ViewHolder{
        TextView tvItemName;
    public ViewHoder(@NonNull View itemView){
        super (itemView);
        tvItemName=itemView.findViewById(R.id.tv_item_name);
        }

        }
    }

